NexusFi: Find Your Edge


Home Menu

 





Can someone tell me why this happens


Discussion in Platforms and Indicators

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




 
Search this Thread

Can someone tell me why this happens

  #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

Can anyone tell me why this code only opens long positions and doesn't open on the next bar after a signal. It also open a trade as soon as i start the EA regardless of when the signal was i.e x bars ago

Thank you

 
Code
                            
//+------------------------------------------------------------------+
//|                                                  A Daytrader.mq4 |
//|                                                               RG |
//|                                                                  |
//+------------------------------------------------------------------+

//---- input parameters

extern double    TakeProfit=70.0;
extern double    Lots=3;
extern double    TrailingStop=15.0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 
   
//----
   
return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   
return(0);
  }


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

   
   
int cnttickettotal;
   
double ArrowUpArrowDown;
   
   
   
   if(
Bars<100)
     {
      Print(
"bars less than 100");
      return(
0);  
     }
   if(
TakeProfit<10)
     {
      Print(
"TakeProfit less than 10");
      return(
0);  // check TakeProfit
     
}
     
     
      
ArrowUp iCustom(NULL,0,"PZ_DayTrading",0,1);
      
ArrowDown iCustom(NULL,0,"PZ_DayTrading",1,1);
   
   
   
   
total  OrdersTotal(); 
   if(
total 1
     
     {
       if  (
ArrowUp!=1)
         {
            
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"DayTrader",12345,0,Green);
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
              }
            
            return(
0);
         }
         else if (
ArrowDown!=2)
         {

            
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"DayTrader",12345,0,Red);
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
              }
            
            return(
0);
         }
         return(
0);
     }
   for(
cnt=0;cnt<total;cnt++)
     
   return(
0);
  }
//+----------------------------------------------------------- 

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
Blash's Avatar
 Blash 
Chicago, IL
Legendary Market Chamois
 
Experience: None
Platform: NT8,NT7,TWS
Broker: InteractiveBrokers, S5T, IQFeed
Trading: The one I'm creating in the present....Index Futures mini/micro, ZF
Posts: 2,311 since Nov 2011
Thanks Given: 7,341
Thanks Received: 4,518

Only problem is what you are asking for in debugging this code can quickly turn into a very time consuming effort. Did you write it?

...My calamity is My providence, outwardly it is fire and vengeance, but inwardly it is light and mercy...
The steed of this Valley is pain; and if there be no pain this journey will never end.
Buy Low And Sell High (read left to right or right to left....lol)
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #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


Hi, thanks for the reply.

I have pulled bits of code from other EAs as I am trying to write my own, and failing. Any assistance on how to correct the issue would be greatly appreciated.

Started this thread Reply With Quote
  #4 (permalink)
 
Blash's Avatar
 Blash 
Chicago, IL
Legendary Market Chamois
 
Experience: None
Platform: NT8,NT7,TWS
Broker: InteractiveBrokers, S5T, IQFeed
Trading: The one I'm creating in the present....Index Futures mini/micro, ZF
Posts: 2,311 since Nov 2011
Thanks Given: 7,341
Thanks Received: 4,518

I assumed it was C# Ninja code because your info says you use Ninja as your platform. But I now see this thread is in the Metatrader sub-forum.
I only do Ninja stuff and very badly at that.....lol
Maybe if you post the file someone might have a better chance of helping out and maybe if you can have a more concrete question narrowed down to a piece of code within the whole....????

...My calamity is My providence, outwardly it is fire and vengeance, but inwardly it is light and mercy...
The steed of this Valley is pain; and if there be no pain this journey will never end.
Buy Low And Sell High (read left to right or right to left....lol)
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (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

https://www.mql5.com/en/charts/3681899/eurusd-m15-fxprimus-ltd

Here you can see a long position open a few bars after the short signal, should have been a short trade. Still no buy orders. No idea whats happening , can anyone help.

Have a missed something in the code relating to my order management.

Started this thread Reply With Quote
  #6 (permalink)
tvtaddy
jammu, india
 
Posts: 2 since Aug 2015
Thanks Given: 0
Thanks Received: 0

Hi, can you elaborate it as I the the informative provided by you is insufficient.

Reply With Quote




Last Updated on August 3, 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