• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 4:19am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 4:19am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Help Needed to Debug Existing EA with proven strategy 759 replies

MT4 EA coder required to fine-tune/debug existing EA 0 replies

Debug code in strategy tester 1 reply

Debug this Indicator please 2 replies

debug message MT4 EA in Strategy Test 7 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 2
Attachments: Help to debug my EA
Exit Attachments
Tags: Help to debug my EA
Cancel

Help to debug my EA

  • Post #1
  • Quote
  • First Post: Sep 25, 2019 10:49am Sep 25, 2019 10:49am
  •  pgtips
  • | Joined Nov 2007 | Status: Member | 162 Posts
Hi,

need some help with my code
I'm trying to do 2 things, trail my open position when it goes into profit by x pips and execute trailingpositions routine

then when price hits + 30 (level set externally by LevelTargetInProfit) then use a different routine which is trailingpositions2

but it will not work for me :-/ It executes routine 2 above 30 pips so I don't have a SL to start whereas I want it to start at -30 and move the SL each time price goes +1

//+------------------------------------------------------------------+
//| Trailing levels |
//+------------------------------------------------------------------+
void CheckPriceAboveorBelowLevel() {
int pr=ProfitPosition(), sl=StopLossInPoint();
int sp=MarketInfo(OrderSymbol(), MODE_SPREAD);

if (pr<LevelTargetInProfit && pr>=-3000 ) {
TrailingPositions();
return;
}

if (pr>LevelTargetInProfit ) {
TrailingPositions2();
return;
}
}

what am I doing wrong ? I need it to trail immediately?
Must I set a SL to start or will MT4 it apply one.
Attached File(s)
File Type: mq4 trailing test.mq4   7 KB | 86 downloads
  • Post #2
  • Quote
  • Sep 25, 2019 12:53pm Sep 25, 2019 12:53pm
  •  pgtips
  • | Joined Nov 2007 | Status: Member | 162 Posts
well i have hacked this which i am testing now , its messy but possibly might work, trouble is markets are v slow at this time of day

Attached File(s)
File Type: mq4 trailing testv2.mq4   8 KB | 84 downloads


* bugger, price just moved but ea did nothing so still got a bug
 
 
  • Post #3
  • Quote
  • Last Post: Sep 26, 2019 7:41am Sep 26, 2019 7:41am
  •  Beerrun
  • Joined Jan 2016 | Status: Good Coder | Bad Trader | 461 Posts
Quoting pgtips
Disliked
Hi, need some help with my code I'm trying to do 2 things, trail my open position when it goes into profit by x pips and execute trailingpositions routine then when price hits + 30 (level set externally by LevelTargetInProfit) then use a different routine which is trailingpositions2 but it will not work for me :-/ It executes routine 2 above 30 pips so I don't have a SL to start whereas I want it to start at -30 and move the SL each time price goes +1 //+------------------------------------------------------------------+ //| Trailing levels | //+------------------------------------------------------------------+...
Ignored
It would help you to add error checking and print statements. Do you have any errors in the experts tab of your terminal?
 
 
  • Platform Tech
  • /
  • Help to debug my EA
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023