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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Need help coding a simple system 4 replies

Help? Simple Question Regarding Arrows Indicator Coding 0 replies

I Will Learn Coding in 1 Month - Give me the 80/20 of MT4 Coding 14 replies

Simple Question, maybe a dumb question 2 replies

simple coding question... 4 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Simple Coding Question....
Cancel

Simple Coding Question....

  • Post #1
  • Quote
  • First Post: May 10, 2008 9:07pm May 10, 2008 9:07pm
  •  X.Oden
  • | Joined Feb 2006 | Status: Spartan Attitude | 1,500 Posts
If I am using pending orders in my code, is there a way to recall the same identical pending order and re-enter it with the same entry,target and exit points?

For example, I use the following pending order:

buystop 1.2000 sl: 1.1950 tp: 1.2100

the order executes, and I want to for example tell the EA that if price dips below the buystop by 10 pips, to re-enter the buystop order at the exact values above again...

Can anyone help me out with the code? I am using ticket1 = OrderSend OP_BUYSTOP for the above......but I am not sure I understand how to store the above trade in a variable to be re-used again in the example given above...
In Charts We Trust!
  • Post #2
  • Quote
  • May 10, 2008 9:42pm May 10, 2008 9:42pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
there are a couple of options.

If the order has not executed yet, you can just scan through looking for your order with the OrderSelect function. Just write a loop that increments by one looking for the order. If it has executed and then closed you can still retrieve the information from the Orderhistory by using the orderselect again but setting one of the parameters to Mode_history. Once the order has been found you can retrieve OrderOpenPrice, Stoploss, etc.

One other option: when the initial order is placed you can store the information in global variables using Globalvariableset and get. Global variables are stored even when mt4 is turned off and are immediately available upon restart.
 
 
  • Post #3
  • Quote
  • May 11, 2008 2:26am May 11, 2008 2:26am
  •  X.Oden
  • | Joined Feb 2006 | Status: Spartan Attitude | 1,500 Posts
So basically I can run an Orderselect by Ticket# and when it finds it, how do I go about re-using the info in another pending order?


Quoting magnumfreak
Disliked
there are a couple of options.

If the order has not executed yet, you can just scan through looking for your order with the OrderSelect function. Just write a loop that increments by one looking for the order. If it has executed and then closed you can still retrieve the information from the Orderhistory by using the orderselect again but setting one of the parameters to Mode_history. Once the order has been found you can retrieve OrderOpenPrice, Stoploss, etc.

One other option: when the initial order is placed you can store the information in global variables using Globalvariableset and get. Global variables are stored even when mt4 is turned off and are immediately available upon restart.
Ignored
In Charts We Trust!
 
 
  • Post #4
  • Quote
  • May 11, 2008 3:48am May 11, 2008 3:48am
  •  Oksana17
  • | Membership Revoked | Joined Sep 2007 | 903 Posts
Quoting X.Oden
Disliked
So basically I can run an Orderselect by Ticket# and when it finds it, how do I go about re-using the info in another pending order?
Ignored
Just write:
PHP Code
 if(OrderSelect(0,0)){
switch(
OrderType()){
case 
0: if(OrderOpenPrice()-Bid>=10*Point)OrderSend(Symbol(),OrderType(),OrderLots(),OrderOpenPrice(),25,OrderStopLoss(),OrderTakeProfit(),OrderComment(),OrderMagicNumber(),OrderExpiration(),Green);break;
case 
1: if(Bid-OrderOpenPrice()>=10*Point)OrderSend(Symbol(),OrderType(),OrderLots(),OrderOpenPrice(),25,OrderStopLoss(),OrderTakeProfit(),OrderComment(),OrderMagicNumber(),OrderExpiration(),Red);break;}} 
Request custom Expert Advisor or Indicator: dostapyuk "at" gmail . com
 
 
  • Post #5
  • Quote
  • May 11, 2008 5:31am May 11, 2008 5:31am
  •  X.Oden
  • | Joined Feb 2006 | Status: Spartan Attitude | 1,500 Posts
Hey thanks....I wrote it a different way, but it works as well...thanks for the advice man. I really appreciate it.

I'm running into a problem however that I can't figure out now.

When I compile the program, no errors.

I go to strategy tester, and the orders are executed, then strategy tester just sits there, not doing anything. I think it goes into the code one run and strategy tester hangs, no errors in the journal log...........
In Charts We Trust!
 
 
  • Post #6
  • Quote
  • May 11, 2008 12:22pm May 11, 2008 12:22pm
  •  Oksana17
  • | Membership Revoked | Joined Sep 2007 | 903 Posts
Quoting X.Oden
Disliked
Hey thanks....I wrote it a different way, but it works as well...thanks for the advice man. I really appreciate it.

I'm running into a problem however that I can't figure out now.

When I compile the program, no errors.

I go to strategy tester, and the orders are executed, then strategy tester just sits there, not doing anything. I think it goes into the code one run and strategy tester hangs, no errors in the journal log...........
Ignored
The logic in the code is wrong. Would you mind posting your code?
Request custom Expert Advisor or Indicator: dostapyuk "at" gmail . com
 
 
  • Post #7
  • Quote
  • May 18, 2008 10:19pm May 18, 2008 10:19pm
  •  X.Oden
  • | Joined Feb 2006 | Status: Spartan Attitude | 1,500 Posts
Sorry, as much as I would, I can't. Its a proprietary system.

Quoting Oksana17
Disliked
The logic in the code is wrong. Would you mind posting your code?
Ignored
In Charts We Trust!
 
 
  • Post #8
  • Quote
  • May 18, 2008 10:24pm May 18, 2008 10:24pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
Quoting X.Oden
Disliked
Sorry, as much as I would, I can't. Its a proprietary system.
Ignored
try testing it live in a demo account. make sure you get a smiley face in the right hand corner. It could be something as simple as you referenced an indicator that doesn't exist or something. Watch the journal for anything that shows up.

I will also, when mt4 frustrates me enough, write some of the values to the screen via the Comment function. This helps me to see if the variables are getting proper values.
 
 
  • Post #9
  • Quote
  • Last Post: May 18, 2008 10:28pm May 18, 2008 10:28pm
  •  tdion
  • Joined Nov 2005 | Status: EURUSD Quant FREAK | 3,197 Posts
it goes long when jerry speaks, and short when elaine speaks.

all orders close when kramer enters.
 
 
  • Platform Tech
  • /
  • Simple Coding Question....
  • 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