• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Strategy Sell before Buy

StockT8er

Member
VIP
How do I code to eliminate this?

See Detail

hsjhrTG.png
 

StockT8er

Member
VIP
Code:
def BuySignal = if BuyDiff crosses above 0  then 1 else 0;
def SellSignal = if SellDiff crosses below 0 then 1 else 0;

AddOrder(OrderType.BUY_TO_OPEN, RTH and (BuySignal + BuySignal[-1]) / 2, price = BuyorderPrice, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "CDS_LE_G");

AddOrder(OrderType.SELL_TO_CLOSE, (SellSignal + SellSignal[-1]) / 2, price = SellorderPrice, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "CDS_SE");
or
AddOrder(OrderType.BUY_TO_OPEN, RTH and BuySignal[-1], price = BuyorderPrice, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "CDS_LE_G");

AddOrder(OrderType.SELL_TO_CLOSE, SellSignal[-1], price = SellorderPrice, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "CDS_SE");

Both will do it when it Buys and sells same bar. it will always list the sell first then buy, therefore not register as a win or loss or break even in the PL_Lablers Strategy
 
Last edited:

StockT8er

Member
VIP
i'm just showing 2 examples of how I have entered them. This one I just coded to see if it would help with false signals, have not tested yet
(BuySignal + BuySignal[-1]) / 2
 

rad14733

Well-known member
VIP
Can't really make a determination without seeing the ENTIRE script... Not providing it just delays your getting a good answer... Give us something to work with...
 

Similar threads

Top