I am trying to program a signal and in the code I want the logic to go between different "stations" for processing. (Sort of like a product travels between different machines for different kinds of processing in a workshop).
I have written a simple verison below, where processing starts at station 1, but when a certain condition is true (as an example I have used the condition "close>100") then the processing moves to station 2. While at station 2 I want the programme to forget all about station 1 (at least until I redirect processing there from code within station 2). However I get the impression that the way Multicharts reads the script, is that as soon as the condition1 becomes untrue (in this case close<100) then Multicharts will start to process things at station1 again!?
Var:
station(1);
if station =1 then begin
//blablabla code
if close>100 then station=2;
end;
if station=2 then begin
//blablabla Code
end;
Have I understood this correctly,? And if so, how can I get around this problem so that I can create a script where the logic moves between different stations, and does not "scip back" to previous stations when conditions within those previous stations change.
I may add that I have no programming background.
Thank you for any input!
Question, execution of signal script [SOLVED]
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Question, execution of signal script
Computers are dumb.I am trying to program a signal and in the code I want the logic to go between different "stations" for processing. (Sort of like a product travels between different machines for different kinds of processing in a workshop).
I have written a simple verison below, where processing starts at station 1, but when a certain condition is true (as an example I have used the condition "close>100") then the processing moves to station 2. While at station 2 I want the programme to forget all about station 1 (at least until I redirect processing there from code within station 2). However I get the impression that the way Multicharts reads the script, is that as soon as the condition1 becomes untrue (in this case close<100) then Multicharts will start to process things at station1 again!?
Var:
station(1);
if station =1 then begin
//blablabla code
if close>100 then station=2;
end;
if station=2 then begin
//blablabla Code
end;
Have I understood this correctly,? And if so, how can I get around this problem so that I can create a script where the logic moves between different stations, and does not "scip back" to previous stations when conditions within those previous stations change.
I may add that I have no programming background.
Thank you for any input!
They will only do what you tell it to do.
If you tell the computer that station=1, it will remember the value and never forget...
until you tell him that station=2.
When station=2, no matter what happens (eg. C<100), station will still =2 unless you specifically tell the computer otherwise.
eg.
Code: Select all
if close<100 then station=1;
ps. [FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713
Re: Question, execution of signal script
Thank you for your reply and your time TJ.
There is a serious problem here. I have written an even more simple script to visualize below, and below it I also paste the content from the Output tab from the Powerlanguage Editor.
The intention is for station 0 to only run once, and then for station 1 to run going forward.
However, while the bar stays the same (bar 51) the logic keeps reverting back to station 0!
Not until a new bar is beginning to form (bar 52), does the logic stay completely at station 1.
This is a serious problem for me, since if I have the order entry function in station 0, I end up sending multiple entries instead of 1 etc.
Please, does anyone have an explanation/solution to this problem which I have spent over a week trying to solve. I tried every workaround possible. Is it a flaw in MC, or am I just dumb?
51.00Print A. Station is 0
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1
There is a serious problem here. I have written an even more simple script to visualize below, and below it I also paste the content from the Output tab from the Powerlanguage Editor.
The intention is for station 0 to only run once, and then for station 1 to run going forward.
However, while the bar stays the same (bar 51) the logic keeps reverting back to station 0!
Not until a new bar is beginning to form (bar 52), does the logic stay completely at station 1.
This is a serious problem for me, since if I have the order entry function in station 0, I end up sending multiple entries instead of 1 etc.
Please, does anyone have an explanation/solution to this problem which I have spent over a week trying to solve. I tried every workaround possible. Is it a flaw in MC, or am I just dumb?
Code: Select all
vars:
station(0);
//Station 0//////////////
if station = 0 then begin
print( maxbarsback+currentbar ,"Print A. Station is ", station:1:0);
station=1;
end;
///////////////////////
//Station 1/////////////
if station = 1 then begin
print( maxbarsback+currentbar ,"Print B. Station is ", station:1:0);
end;
//////////////////////
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
51.00Print A. Station is 0
51.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1
52.00Print B. Station is 1