NexusFi: Find Your Edge


Home Menu

 





A little help with EA code using icustom please


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,663 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 2 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

Hi all,

I am trying to learn how to programme my own expert advisor, i am sure you will all be shocked at how simple this code is but I am learning so please help me and point out where I am going wrong.

I have an indicator that I use, super_signals_v2_Alert.mq4, this paints green or red buy and sell signals and then sound an alert. When a green signal is painted I would like to open a long market order at the open of the next bar.

When a red signal is painted I would like to open a shoprt market entry at the open of the next bar.

If a long position is open and anotherr signal is painted in the same direction, it is ignored, only 1 trade open in any direction at any time.

If an opposing signal sounds then this closes the trade. I would like to have an option to have the EA always in the market so reverse when an opposing signal is triggered.

I have been trying to get this right but I am having no luck...

Here is what I have so far but I am not sure if the condition to open and close is correct as per the indicator as it doesnt open trades when the indicator alarms, it only buys and opens multiple trades in the same direction.

#include <stdlib.mqh>

extern double downtrend;// downtrend=iCustom(NULL,0,"super_signals_v2_alert",1,0); ???
extern double uptrend; // uptrend=iCustom(NULL,0,"super_signals_v2_alert",0,0); ???
extern int dist2=21;
extern int SignalBar=1;
input double lots=3;
input double TakeProfit=550;
int OpenOrders=0, cnt=0;

int start()

{

int downtrend = iHighest(NULL,0,MODE_HIGH,dist2,SignalBar-dist2/2);
int uptrend = iLowest(NULL,0,MODE_LOW,dist2,SignalBar-dist2/2);


if(downtrend && OpenOrders<1)
{
bool ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,Bid+TakeProfit*Point,NULL,0,0,clrRed);
}
else if(uptrend && OpenOrders<1)
{
ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,Ask+TakeProfit*Point,NULL,0,0,clrGreen);


}
}



Can someone please help me out here, it would be greatly appreciated.

Thanks

Attached Files
Elite Membership required to download: tester.mq4
Elite Membership required to download: super_signals_v2_Alert.mq4
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
MC Advanced Simulated Trading.
MultiCharts
tick data interval discrepancy
NinjaTrader
Has anyone taken The Confident Trader course from aheadc …
Trading Reviews and Vendors
What You Know vs How much you know about it
Traders Hideout
 




Last Updated on May 6, 2014


© 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