Page 1 of 1

Questions about strategy writing

PostPosted: Sun Aug 27, 2017 8:16 pm
by guangho
Hello everyone,I have one questions about strategy writing。。。

The execution command is like this:
function enter(BuySell)
......
valuemap=core.valuemap();
valuemap.Command="CreateOrder";
......
success,msg=terminal:execute(2000,valuemap);
if not(success) then executing=false;
terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order failed"..msg,instance.bid:date(NOW));
else terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order true"..msg,instance.bid:date(NOW));
end
end

that how to write “function ExtAsyncOperationFinished()”?。。。

First kind:
function ExtAsyncOperationFinished(cookie,success,message)
if cookie==2000 and not(success) then
terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order failed"..message,instance.bid:date(NOW));
end
end

Second kinds:
function ExtAsyncOperationFinished(id,success,message)
if id==2000 and not(success) then
terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order failed"..message,instance.bid:date(NOW));
end
end

Questions1:How to write “function ExtAsyncOperationFinished()”?
Questions2:Is the effect of the two writing the same?
Questions3:The “cookie” is Specific time for second?

thank you verymuch!

Re: Questions about strategy writing

PostPosted: Tue Aug 29, 2017 3:07 am
by IgorNI
Hi, guangho

> The “cookie” is Specific time for second?
A cookie is a small string contains user specific data.
A server can send a cookie to a client in HTTP response and gets it from a client in HTTP request.
The cookie allows identifying a user. It can contain any textual information (time, userid or whatever else).

> Is the effect of the two writing the same?
Yes, it is.
Name of function parameters can be changed without any effect.

> How to write “function ExtAsyncOperationFinished()”?
You can find an example here: https://github.com/FXCMAPI/FXCM-API-Off ... rategy.lua

Re: Questions about strategy writing

PostPosted: Wed Aug 30, 2017 4:39 am
by guangho
IgorNI wrote:Hi, guangho

> The “cookie” is Specific time for second?
A cookie is a small string contains user specific data.
A server can send a cookie to a client in HTTP response and gets it from a client in HTTP request.
The cookie allows identifying a user. It can contain any textual information (time, userid or whatever else).

> Is the effect of the two writing the same?
Yes, it is.
Name of function parameters can be changed without any effect.

> How to write “function ExtAsyncOperationFinished()”?
You can find an example here: https://github.com/FXCMAPI/FXCM-API-Off ... rategy.lua



Thank you for your answer!
I want to add a delay in the “function ExtAsyncOperationFinished()”. How should I write it?

Re: Questions about strategy writing

PostPosted: Thu Aug 31, 2017 2:34 am
by IgorNI
Hi, guangho

> I want to add a delay in the “function ExtAsyncOperationFinished()”
If you do this in the ExtAsyncOperationFinished() then it will freeze thread and UI.
If you need to run some code after a delay, the best option is using a timer.

You can find an example here:
http://www.fxcodebase.com/documents/Ind ... oader.html

Re: Questions about strategy writing

PostPosted: Thu Aug 31, 2017 5:18 am
by guangho
IgorNI wrote:Hi, guangho

> The “cookie” is Specific time for second?
A cookie is a small string contains user specific data.
A server can send a cookie to a client in HTTP response and gets it from a client in HTTP request.
The cookie allows identifying a user. It can contain any textual information (time, userid or whatever else).

> Is the effect of the two writing the same?
Yes, it is.
Name of function parameters can be changed without any effect.

> How to write “function ExtAsyncOperationFinished()”?
You can find an example here: https://github.com/FXCMAPI/FXCM-API-Off ... rategy.lua


The execution command is like this:
function enter(BuySell)
valuemap=core.valuemap();
valuemap.Command="CreateOrder";
....
success,msg=terminal:execute(2000,valuemap);
if not(success) then executing=false;
terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order failed"..msg,instance.bid:date(NOW));
else terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order true"..msg,instance.bid:date(NOW));
end
end

function ExtAsyncOperationFinished(id,success,message)
if id==2000 and not(success) then
executing=false;
enter(BuySell);
terminal:alertMessage(instance.bid:instrument(),instance.bid[NOW],"Open order once again"..message,instance.bid:date(NOW)) end
end

The reply received is attached to the drawings.
I want to do it again when open order failed defeated,but not implemented...
Do you know why?How to write?
Thank you!

QQ截图20170831085148.png

QQ截图20170831085345.png

Re: Questions about strategy writing

PostPosted: Fri Sep 01, 2017 3:11 am
by IgorNI
Hi, guangho

In a simple case, you can use global variables for storing order creation parameters.
Move the order creation code to own function, for example,

function CreateOrder()
(..)

And then call it in the ExtAsyncOperationFinished() function again when open order creation has failed.

Re: Questions about strategy writing

PostPosted: Fri Sep 01, 2017 5:57 am
by guangho
IgorNI wrote:Hi, guangho

In a simple case, you can use global variables for storing order creation parameters.
Move the order creation code to own function, for example,

function CreateOrder()
(..)

And then call it in the ExtAsyncOperationFinished() function again when open order creation has failed.


Thank you for your reply...
Can you give me an example?
Thank you very much...

Re: Questions about strategy writing

PostPosted: Fri Sep 08, 2017 9:20 am
by PetroIV
Hello,

I have attached a strategy that in the case of error in ExtAsyncOperationFinished, repeated request for the creating order.

Thanks.

Re: Questions about strategy writing

PostPosted: Mon Dec 11, 2017 1:15 pm
by maximekaribi
HELLO
IS THERE A STRATEGY BASED ON SIMPLE INSIDE BAR AND WHERE IT IS POSSIBLE TO TAKE ONLY INSIDE BAR WITH A NUMBER OF PIPS PREDETERMINED FOR EACH PAIR?
THANK YOU VERY MUCH

Re: Questions about strategy writing

PostPosted: Fri Dec 15, 2017 8:27 am
by Apprentice