Supply and demand

#1
Any one please correct this afl . May be it will be useful
1. KL Street stocks were set to buy / sell order:
/ / Set Variables
barvisible = Status ( "barvisible");
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

CC = "CC_" + Name ();

KLMua = Prc (Foreign (CC, "V", 0), 0);
KLBan = Prc (Foreign (CC, "interest", 0), 0);

/ KLMua = OpenInt;
_SECTION_BEGIN ( "KLMua");
Plot (KLMua, "volume purchase", colorBlue, styleThick);
_SECTION_END ();

_SECTION_BEGIN ( "KLBan");
Plot (KLBan, "the volume, colorRed, styleThick);
_SECTION_END ();
2. Number of command set buy / sell order of the day:
/ / Set Variables
barvisible = Status ( "barvisible");
FVB = barvisible AND NOT Ref (barvisible, -1);
CVB = ValueWhen (FVB, C);
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

CC = "CC_" + Name ();

Foreign SLBan = (CC, "C", 0);
Foreign SLMua = (CC, "O", 0);

_SECTION_BEGIN ( "SLMua");
Plot (SLMua, "commands buy" colorBlue, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "SLBan");
Plot (SLBan, "the command prompt," colorRed, ParamStyle ( "Style", styleThick));
_SECTION_END ();
3. The average first order purchase as much CP (BB for small purchases or buy)
/ / Set Variables
barvisible = Status ( "barvisible");
FVB = barvisible AND NOT Ref (barvisible, -1);
CVB = ValueWhen (FVB, C);
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

CC = "CC_" + Name ();

Foreign SLBan = (CC, "C", 0);
Foreign SLMua = (CC, "O", 0);

KLMua = Prc (Foreign (CC, "V", 0), 0);
KLBan = Prc (Foreign (CC, "interest", 0), 0);

TBLenhmua = IIF (SLMua! = 0, KLMua / SLMua, 0);
TBLenhBan = IIF (SLBan! = 0, KLBan / SLBan, 0);
TBMuachiaTBBan = IIF (TBLenhBan! = 0, TBLenhmua / TBLenhBan * 100.0);

_SECTION_BEGIN ( "TBLenhmua");
Plot (TBLenhmua, "TB lenh buy", colorBlue, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "TBLenhban");
Plot (TBLenhban, "TB command you", colorRed, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "TBMuachiaTBBan");
Plot (TBMuachiaTBBan, "Ti le Purchase / Board (%)", colorGreen, ParamStyle (" Style ", styleHistogram));
_SECTION_END ();

4. KL CP Oversea purchase and sale Net:
/ / Set Variables
barvisible = Status ( "barvisible");
FVB = barvisible AND NOT Ref (barvisible, -1);
CVB = ValueWhen (FVB, C);
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

NN = "NN_" + Name ();

Foreign KLBan = (NN, "C", 0);
Foreign KLMua = (NN, "O", 0);

_SECTION_BEGIN ( "KLMua");
Plot (KLMua, "NN purchased (KL)", colorBlue, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "KLBan");
Plot (KLBan, "Agriculture Committee (KL)", colorRed, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "FOREIGN TRADING");
Plot (OI, _DEFAULT_NAME (), ParamColor ( "Color", colorBlueGrey), ParamStyle ( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram), 2);
_SECTION_END ();

5. TB on a purchase price of the CP NN (for the shift direction of the BCS NN or PSS)
/ / Set Variables
barvisible = Status ( "barvisible");
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

NN = "NN_" + Name ();

GTMua = Prc (Foreign (NN, "V", 0), 0);
GTBan = Prc (Foreign (NN, "interest", 0), 0);

/ GTMua = OpenInt;
_SECTION_BEGIN ( "GTMua");
Plot (GTMua, "NN purchase (GT)", colorBlue, styleThick);
_SECTION_END ();

_SECTION_BEGIN ( "GTBan");
Plot (GTBan, "Agriculture Committee (GT)", colorRed, styleThick);
_SECTION_END ();

6. TB rates in the CP that a foreign purchase (with recipes for five of the NN direction shifted the BCS or PSS)
/ / Set Variables
barvisible = Status ( "barvisible");
FVB = barvisible AND NOT Ref (barvisible, -1);
CVB = ValueWhen (FVB, C);
ValueWhen Leftbar = (Ref (barvisible, -1) == 0 AND barvisible, DateTime ());
LastValue Rightbar = (DateTime ());
DateSpan = EndValue (BarIndex ()) - BeginValue (BarIndex ());
Range = DateSpan;
StartDate = BeginValue (BarIndex ());
EndDate = EndValue (BarIndex ());

NN = "NN_" + Name ();

Foreign KLBan = (NN, "C", 0);
Foreign KLMua = (NN, "O", 0);

GTMua = Prc (Foreign (NN, "V", 0), 0);
GTBan = Prc (Foreign (NN, "interest", 0), 0);

TBGiaMua = IIF (KLMua! = 0, GTMua / KLMua, 0);
TBGiaBan = IIF (KLBan! = 0, GTBan / KLBan, 0);
TBGiaMuaBan = IIF (TBGiaBan! = 0, TBGiaMua / TBGiaBan * 100.0);

_SECTION_BEGIN ( "TBGiaMua");
Plot (TBGiaMua, "NN (TBgiamua)", colorBlue, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "TBGiaBan");
Plot (TBGiaBan, "NN (TBgiaban" colorRed, ParamStyle ( "Style", styleThick));
_SECTION_END ();

_SECTION_BEGIN ( "TBGiaMuaBan");
Plot (TBGiaMuaBan, "TileGiaMua / Board (%)", colorGreen, ParamStyle (" Style ", styleHistogram));
_SECTION_END ();
 
#2
The source of this code is from www.vinase.com. You should understand how the data is organised, then the logic of code runs. Without data structure, this code may be useless or falsely signaling.

You may ask CAS67 for translating the logic into English for you(That guy may understand vietnamese, I guess).
 

Similar threads