NexusFi: Find Your Edge


Home Menu

 





Open trade and closing trade on reverse signal


Discussion in Platforms and Indicators

Updated
    1. trending_up 2,017 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
ryangillespie's Avatar
 ryangillespie 
london, England
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL, ES
Posts: 41 since Nov 2011
Thanks Given: 10
Thanks Received: 2

I am trying to write an EA using an indicator with icustom.

How can I get the EA to close an open trade when an alternate signal is fired. Also how can I send a market order on the next bar when the signal has fired.

extern double downtrend;
extern double uptrend;
input double lots=1;



int start()


{

int downtrend = downtrend=iCustom(NULL,0,"DayTrading",2,0);
int uptrend = uptrend=iCustom(NULL,0,"DayTrading",1,0);


if(downtrend)
{
bool ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,0,0,0,"DayTrading",16384,0,Red);
}
else if(uptrend)
{
ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,0,"DayTrading",16384,0,Green);
}
}



Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to plot a custom icon for crossover
NinjaTrader
Pivot Indicator based on Level2 data
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
tick data interval discrepancy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
ApexTraderFunding.com experience and review
74 thanks
HumbleTraders next chapter
51 thanks
Winning attitudes create winning traders
39 thanks
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Topstep experience and review
33 thanks
  #3 (permalink)
 
ryangillespie's Avatar
 ryangillespie 
london, England
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL, ES
Posts: 41 since Nov 2011
Thanks Given: 10
Thanks Received: 2


 
Code
                            
extern double Lots 2;

extern double Slippage 2.0;
extern int    MagicNr=9502;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()



 { 
  
double ArrowUpArrowDown;
  static 
int iBuyTicket=-1;
  static 
int iSellTicket=-1;
  static 
datetime tCurTime;
 
  
  
// Get Supersignal state
  
ArrowUp iCustom(NULL,0,"PZ_DayTrading",1,0);
  
ArrowDown iCustom(NULL,0,"PZ_DayTrading",2,0);
  
  
// Open orders on new bar only
  
if (tCurTime != Time[0]) {
    
tCurTime=Time[0];
    
    
// Open Buy order if previous bar has arrow up signal
    
if  (ArrowUp!=&& iBuyTicket<0
      
iBuyTicket=OrderSend(Symbol(),OP_BUY,LotsAskSlippage00
                
"DayTrade"MagicNrNULLLimeGreen);    
    
    
// Open Sell order if previous bar has arrow up signal
    
else if  (ArrowDown!=&& iSellTicket<0) {
      
iSellTicket=OrderSend(Symbol(),OP_SELL,LotsBidSlippage00,
                
"DayTrade"MagicNrNULLLimeGreen);    
    }
  } 
Now the EA opens various trades, it should only open a single position the bar after the indicator has signalled an arrow.

Also how do I close an open position when an opposite signal occurs.

Thank you all

Started this thread Reply With Quote




Last Updated on July 8, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts