EMA Crossover strategy is not doing automatic buy/sell - please help me.

chIza=iChis1A?H

Member
VIP
Hello everyone,
I am a new to Thnikscript and using the below script, which shows the crossover including arrows when it happenes but the code doesn;t BUY or SELL automatically, any reason why. Thanking you in advance.

+++++++++++++++++++++++++++++++++++

input longEntries = yes;
input ShortEntries = no;
#-------------------------------------------------------
# For future , we would always like to trade only "1" contract, at a time
#-------------------------------------------------------
input qty = 1;
input FastEMALength = 13;
input SlowEMALength = 48;
input AverageTypeFast = AverageType.EXPONENTIAL;
input AverageTypeSlow = AverageType.EXPONENTIAL;

plot fastMA = MovingAverage ( AverageTypeFast, close, FastEMALength );

plot slowMA = MovingAverage ( AverageTypeSlow, close, SlowEMALength );

AddOrder ( OrderType.BUY_TO_OPEN , ( longEntries) and fastMA crosses above slowMA, close, qty);

AddOrder ( OrderType.SELL_TO_CLOSE, fastMA crosses below slowMA, close, qty);


AddOrder ( OrderType.SELL_TO_OPEN, ( ShortEntries ) and fastMA crosses above slowMA, close, qty);

AddOrder ( OrderType.BUY_TO_CLOSE, fastMA crosses above slowMA, close, qty);
++++++++++++++++++++++++++++++++
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Hello everyone,
I am a new to Thnikscript and using the below script, which shows the crossover including arrows when it happenes but the code doesn;t BUY or SELL automatically, any reason why. Thanking you in advance.
The above script is for testing purposes only. The ToS platform does not support auto buying/selling.
 

chIza=iChis1A?H

Member
VIP
Thanks MerryDay, you mean there is an issue with trhis script or for any indicator the automatic buy / sell doesn;t work ??

so that mean do I have to take an action of buy and sell for each crossover ??

Since so far mainly I am using TOS for options and want to explore more for micro futures trading, I have been using Nionja traders which does allowes strategy to buy/sell as per your code, so want to know if TOS support the same or not ??

Thanks
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
one more question , in that case what is the use of ADDORDER function ?? just want to know if it doesn;t perform buy/sell ??
AddOrder is for backtesting purposes only. The ToS platform does not support auto buying/selling. Orders can be placed manually or there
is limited conditional orders that can be placed but they are one-time only and then expire.
 

chIza=iChis1A?H

Member
VIP
Thanks a lot MerryDay for your reply. Appreciate your help. I was under impression that like as many other tools for trading we can do the same here in TOS too, but good to know. appreciate your help.
 

Similar threads

Top