need help finishing strategy code

BG1328

New member
I am nearly done with this one but can't quite get it to acknowledge a line without it showing up in red. Very new to think script. Any help is greatly appreciated.

Code:
input price = close;
input desiredentryvma = 9;
input desiredexitvma = 9;

def entryvma = VMA (legnth = desiredentryvma);
def exitvma = VMA  (legnth = desiredexitvma);

def buylong = price >  entryvma;
def selllong = price < exitvma;

AddOrder(OrderType.BUY_TO_OPEN, buylong, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "open");


AddOrder(OrderType.BUY_TO_CLOSE, selllong, tickcolor = Color.RED, arrowcolor = Color.RED, name = "CLOSE");
 

halcyonguy

Active member
VIP
this is what i see, an error with vma( )
there isn't a study by that name.
what are you trying to do ?
d5bluKG.jpg


also, i think you will want to replace this
AddOrder(OrderType.BUY_TO_CLOSE,
with
AddOrder(OrderType.sell_TO_CLOSE,
 

GeeVeee

New member
ill want to replace this
I am nearly done with this one but can't quite get it to acknowledge a line without it showing up in red. Very new to think script. Any help is greatly appreciated.

Code:
input price = close;
input desiredentryvma = 9;
input desiredexitvma = 9;

def entryvma = VMA (legnth = desiredentryvma);
def exitvma = VMA  (legnth = desiredexitvma);

def buylong = price >  entryvma;
def selllong = price < exitvma;

AddOrder(OrderType.BUY_TO_OPEN, buylong, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "open");


AddOrder(OrderType.BUY_TO_CLOSE, selllong, tickcolor = Color.RED, arrowcolor = Color.RED, name = "CLOSE");


I think you are trying to use Variable Moving Avarege. If it is the case, the code should be like below. Order type also corrected. Please see the corrections in bold:

input price = close;
input desiredentryvma = 9;
input desiredexitvma = 9;

def entryvma = VariableMA(close, desiredentryvma);
def exitvma = VariableMA(close,desiredexitvma);

def buylong = price > entryvma;
def selllong = price < exitvma;

AddOrder(OrderType.BUY_TO_OPEN, buylong, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "open");

AddOrder(OrderType.SELL_TO_CLOSE, selllong, tickcolor = Color.RED, arrowcolor = Color.RED, name = "CLOSE");
 

Similar threads

Top