OrderSend color ignored - algorithmic-trading

Does somebody know why the color arrow isnt get painted in the next order call?
OrderSend(symbolName, lotsNumber, bid, slip, 0, takeProfit, coment, Red);
Thanks!

Check MQL4 Syntax:
iORS = OrderSend( Symbol(), // .SYM
OP_SELL, // .OP <------------------------- MISSING
dLots, // .LT
Bid, // .ENTRY
5, // .SLIPPAGE
0, // .SL
0, // .TP
sSHORT, // .COMMENT
2000, // .MAGNUM <--------------------- Red
0, // .EXPIRE
Red // .CLR
);
Test ( always ) Return Value:
if ( iORS == EMPTY ) {... /* HANDLE FAILED OrderSend() */ }

Related

How to set a distinct variables to each element in a list in sass?

I created a list for all darken and lighten colors that want to use in my project with the help of sass functions and lists. Here is the code of _functions.scss file:
_functions.scss:
#use "sass:list";
#use "sass:color";
#use "sass:string";
#use "sass:map";
#function themeAllGenerate($themeVar, $changeProp, $per) {
$returnedTheme: ();
#for $counter from 1 through list.length($themeVar) {
$currentColor: list.nth($themeVar, $counter);
#if ($changeProp == "lightness") {
$returnedTheme: list.append($returnedTheme, color.scale($currentColor, $lightness: $per), $separator: comma);
} #else if ($changeProp == "blackness") {
$returnedTheme: list.append($returnedTheme, color.scale($currentColor, $blackness: $per), $separator: comma);
} #else {
#error "Unknown change props #{$changeProp}!";
}
}
#return $returnedTheme;
}
#function lightDark($themVarConfig, $baseTheme) {
#each $name, $value in $themVarConfig {
$black-light: "";
$degree: 17%;
#if string.index($name, "lighten") {
$black-light: "lightness";
} #else {
$black-light: "blackness";
}
#if string.index($name, "2") {
$degree: 49%;
}
$newValue: themeAllGenerate($baseTheme, $black-light, $degree);
$themVarConfig: map.set($themVarConfig, $name, $newValue);
}
#return $themVarConfig;
}
Also here is the code of my _variables.scss file that finally makes the $listThemes variable that contains colors:
_variables.scss:
/* this file is responsible for variables that are used in this project */
#use "functions";
#use "sass:string";
#use "sass:list";
/* color-variables */
/* ----------------------------------- */
/* theme-1 */
/* ----------------------------------- */
$primary-color1: rgb(48, 146, 196);
$secondary-color1: rgb(132, 156, 224);
$text-color1: rgb(201, 249, 136); // this color must have a good contrast with "$back-ground1" color
$background-color1: rgb(3, 58, 32);
$info-color1: rgb(103, 14, 181);
$theme1: ($primary-color1, $secondary-color1, $text-color1, $background-color1, $info-color1);
/* theme-2 */
/* ----------------------------------- */
$primary-color2: rgb(23, 197, 200);
$secondary-color2: rgb(251, 38, 66);
$text-color2: rgb(3, 58, 32); // this color must have a good contrast with "$back-ground1" color
$background-color2: rgb(191, 243, 215);
$info-color2: rgb(99, 4, 56);
$theme2: ($primary-color2, $secondary-color2, $text-color2, $background-color2, $info-color2);
/* building lightness and darkness of colors */
/* ----------------------------------- */
$theme-config-1: ("theme1-lighten-1": null, "theme1-lighten-2": null, "theme1-darken-1": null, "theme1-darken-2": null);
$theme-config-2: ("theme2-lighten-1": null, "theme2-lighten-2": null, "theme2-darken-1": null, "theme2-darken-2": null);
$themes: ($theme1, $theme2);
$listThemes: ($theme-config-1, $theme-config-2);
#for $counterHere from 1 through list.length($listThemes) {
$outPutTheme: functions.lightDark(list.nth($listThemes, $counterHere), list.nth($themes, $counterHere));
$listThemes: list.set-nth($listThemes, $counterHere, $outPutTheme);
}
#debug $listThemes;
That works correctly and gives me the colors I want like below:
("theme1-lighten-1": (#4ea6d4, #99ade5, #d2fa9c, #078348, #8312e7), "theme1-lighten-2": (#92c9e4, #c0cdef, #e3fcc2, #25f492, #b36af3), "theme1-darken-1": (#307ca3, #8492ba, #b1cf88, #03301b, #570e96), "theme1-darken-2": (#305264, #7b7b7b, #838383, #031e11, #380e5c)), ("theme2-lighten-1": (#7ceef0, #fd909f, #25f492, #def9eb, #f737a0), "theme2-lighten-2": (#7ceef0, #fd909f, #25f492, #def9eb, #f737a0), "theme2-darken-1": (#176566, #802632, #031e11, #979797, #32041d), "theme2-darken-2": (#176566, #802632, #031e11, #979797, #32041d))
But the problem is that I want to set distinct variables for each color value inside list. For example a code like this one:
$counterLimit: list.length($theme-config-1);
$counterLimit1: list.length($theme1);
#for $counterFinal from 1 through list.length($listThemes) {
#for $counterFinal2 from 1 through $counterLimit {
#for $counterFinal3 from 1 through $counterLimit1 {
#debug list.nth(list.nth( list.nth( list.nth($listThemes, $counterFinal) , $counterFinal2 ) , 2), $counterFinal3);
/* the above #debug must be something like this:
-----------------------------------------------------
$variableDynamicName: list.nth(list.nth( list.nth( list.nth($listThemes, $counterFinal) , $counterFinal2 ) , 2), $counterFinal3);
-----------------------------------------------------
where "$variableDynamicName" must be set at each loop iteration to some values like "primary1-lighten1", "secondary1-lighten1", ... "info2-darken2".
*/
}
}
}
I don't know how to set variable name dynamically! I don't want that each time I need a color value in my style-sheets, I use a list or map function like list.nth(list.nth(... to obtain the value, I just want to call a variable name like:
h3 {
color: variables.$secondary1-darken1;
}
Is there any solution for that?

How to do PerspectiveCamera panning with Left mouse button in Trackball controls (r87)?

By default, Camera panning is with right mouse button
Control.panSpeed = 1.5;
but I want it to work in left mouse button. How to set this?
This requires an easy modification to the trackball code.
If you look at TrackballControls.js, the very beginning details the keycode-correlated state machine (source code):
THREE.TrackballControls = function ( object, domElement ) {
var _this = this;
var STATE = {NONE: -1, ROTATE: 0, ZOOM: 1, PN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PANE: 4};
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
// API
this.enabled = true;
this.screen = { left: 0, top: 0, width: 0, height: 0 };
Which is related to the keydown() function further down (source code):
function keydown( event ) {
if ( _this.enabled === false ) return;
window.removeEventListener( 'keydown', keydown );
_prevState = _state;
if ( _state !== STATE.NONE ) {
return;
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ){
_state = STATE.ROTATE;
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noZoom ){
_state = STATE.ZOOM;
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noPan ){
_state = STATE.PAN;
}
So, I haven't had a chance to test this, but you should be able to change PAN in line 11 from 2 (the keycode for Right Click) to 0 (Left Click) or any other keycode you want. Remember to change ROTATE as well to avoid the bug-prone directive of rotating and panning at the same time.
EDIT: per #TheJim01's helpful correction, the actual click event triggering actually happens in function mousedown( event ) on line 393 of the script. event.button corresponds to the respective number in the state machine. Sorry about the confusion.

How to make Gtk.DrawingArea visible in a Gtk.Fixed container, if possible?

My Gtk.DrawingArea appears only if I add it as a widget to the main window. If there is a fixed container in the Window and I add the DrawingArea to the fixed container, I see nothing. But I know the draw signal is been called when debugging.
Gtk.DrawingArea drawing_area = new Gtk.DrawingArea ();
drawing_area.draw.connect ((context) => {
context.set_source_rgba (1, 0, 0, 1);
context.rectangle (25, 25, 100, 100);
context.fill ();
return true;
});
// Doesn't work, nothing is visible
fixed.put (drawing_area, 25, 25);
The variable fixed is of type Gtk.Fixed. fixed is the only child widget of the main window. I must mention that if I add any other normal Gtk Widget to fixed, like a label, said label is visible.
If I, instead of adding fixed to my main window, I add the drawing area as the only child of the main window like in the following code, it displays
// Works, rectangle is visible
app_window.add (drawing_area);
app_window is of type Gtk.ApplicationWindow.
Is it possible to make it visible while being a child of Fixed?
----------Edit----------
The Gtk.DrawingArea now appears in the fixed container if I set the size requests for it. Like this
Gtk.DrawingArea drawing_area = new Gtk.DrawingArea ();
drawing_area.width_request = 100;
drawing_area.height_request = 100;
drawing_area.draw.connect ((context) => {
context.set_source_rgba (1, 0, 0, 1);
context.rectangle (0, 0, drawing_area.get_allocated_width (), drawing_area.get_allocated_height ());
context.fill ();
return true;
});
I don't know if this is the correct way to go about it. It works though. The DrawingArea widget with the rectangle displays now in the fixed container. I'll listen to other answers if there is a recommended way to go about it.
One has to set the size requests of the Gtk.DrawingArea widget.
Gtk.DrawingArea drawing_area = new Gtk.DrawingArea ();
drawing_area.width_request = 100;
drawing_area.height_request = 100;
drawing_area.draw.connect ((context) => {
context.set_source_rgba (1, 0, 0, 1);
context.rectangle (0, 0, drawing_area.get_allocated_width (), drawing_area.get_allocated_height ());
context.fill ();
return true;
});

Toggle function not working in Processing (ControlP5)

I just made my image generator work with PNG files. For now, it's divided into 3 categories (backgrounds, objects & texts). These are now all combined, and with every mouse click it randomises these PNGs.
I made three toggles, where you could to choose to show either the background and the objects on top, all of them, or all separate. Whenever I run the sketch, it shows the "grey" background, but when I use the toggles, it doesn't show anything, or shows a flickering image, where the mouse-click can't be used to go to the next image. I can't seem to find the problem. Hopefully, you can help. :)
import controlP5.*;
boolean showBackground = false;
boolean showObjects = false;
boolean showGrids = false;
ControlP5 cp5;
PImage[] myImageArray = new PImage[8];
PImage[] myImageArray2 = new PImage[15];
PImage[] myImageArray3 = new PImage[15];
void setup() {
size(1436, 847);
background(211, 211, 211);
for (int i=0; i<myImageArray.length; i++) {
myImageArray[i] = loadImage ( "o" + i + ".png");
myImageArray2[i] = loadImage ( "g" + i + ".png");
myImageArray3[i] = loadImage( "b" + i + ".jpg");
cp5 = new ControlP5(this);
// create a toggle and change the default look to a (on/off) switch look
cp5.addToggle("showBackground")
.setPosition(40, 250)
.setSize(50, 20)
.setValue(true)
.setMode(ControlP5.SWITCH);
cp5.addToggle("showObjects")
.setPosition(40, 400)
.setSize(50, 20)
.setValue(true)
.setMode(ControlP5.SWITCH);
cp5.addToggle("showGrid")
.setPosition(40, 600)
.setSize(50, 20)
.setValue(true)
.setMode(ControlP5.SWITCH);
}
display();
}
void display() {
image(myImageArray3[(int)random(myImageArray.length)], 0, 0, 1436, 847); // b
image(myImageArray2[(int)random(myImageArray.length)], 0, 0, 1436, 847); // g
image(myImageArray[(int)random(myImageArray.length)], 0, 0, 1436, 847); // o
}
void mousePressed() {
display();
}
void draw() {
pushMatrix();
if (showBackground==false) {
image(myImageArray3[(int)random(myImageArray.length)], 0, 0, 1436, 847); // b
} else {
background(211, 211, 211);
}
if (showGrids==false) {
image(myImageArray2[(int)random(myImageArray.length)], 0, 0, 1436, 847); // g
} else {
background(211, 211, 211);
}
if (showObjects==false) {
image(myImageArray[(int)random(myImageArray.length)], 0, 0, 1436, 847); // o
} else {
background(211, 211, 211);
}
popMatrix();
}
Here are a couple of things where the logic your wrote in your code might not match what you had in mind:
When you call display() on mouse it renders those 3 images once (also it will be different images within those since it's using a randomised index). Similarly in draw(), when an does get picked to be rendered, frames will be flickering fast as a random index is generated multiple times per second(each frame). You may want to randomise indices in a different event (e.g. mouse or key press) and store this value in a variable you can re-use.
the conditions you use in draw(): you probably meant to check if the values are true(toggled enabled/turned on in controlP5) ? (e.g. e.g. if (showBackground==true) and initialise the toggles with false, instead of true?)
a big one: in draw() , after each condition(showBackground,showGrids,showObjects), if it's false, you're clearing the the whole frame (so a previous image would be erased)
you have 3 arrays, but you use the size of the first(myImageArray.length) only, which means, even though you may have more images for myImageArray2 and myImageArray3, you're not loading, nor displaying them.
The third grid is labeled "showGrid" when it should be "showGrids": if you aren't consistent with the toggle labels and variable names, toggles won't update the variable names.
you should use more descriptive names for the arrays: it will make it easier to scan/follow your code on the long run.
there's no need to add toggles multiple times in the for loop where you load images: once will do.
Here's what I mean:
import controlP5.*;
boolean showBackground = false;
boolean showObjects = false;
boolean showGrids = false;
ControlP5 cp5;
PImage[] objects = new PImage[8];
PImage[] grids = new PImage[15];
PImage[] backgrounds = new PImage[15];
int currentImage = 0;
void setup() {
size(1436, 847);
//load objects
for (int i=0; i<objects.length; i++) {
objects[i] = loadImage ( "o" + i + ".png");
}
//load grids
for(int i = 0 ; i < grids.length; i++){
grids[i] = loadImage ( "g" + i + ".png");
}
//load backgrounds
for(int i = 0 ; i < grids.length; i++){
backgrounds[i] = loadImage( "b" + i + ".jpg");
}
//setup UI
cp5 = new ControlP5(this);
// create a toggle and change the default look to a (on/off) switch look
cp5.addToggle("showBackground")
.setPosition(40, 250)
.setSize(50, 20)
.setValue(false)
.setMode(ControlP5.SWITCH);
cp5.addToggle("showObjects")
.setPosition(40, 400)
.setSize(50, 20)
.setValue(false)
.setMode(ControlP5.SWITCH);
cp5.addToggle("showGrids")
.setPosition(40, 600)
.setSize(50, 20)
.setValue(false)
.setMode(ControlP5.SWITCH);
}
void mousePressed() {
//go to next image index
currentImage = currentImage + 1;
//check if the incremented index is still valid, otherwise, reset it to 0 (so it doesn't go out of bounds)
if (currentImage >= objects.length) {
currentImage = 0;
}
}
void draw() {
//clear current frame
background(211);//for gray scale value you can just use one value: the brightness level :)
if (showBackground==true) {
image(backgrounds[currentImage], 0, 0, 1436, 847); // b
}
if (showGrids==true) {
image(grids[currentImage], 0, 0, 1436, 847); // g
}
if (showObjects==true) {
image(objects[currentImage], 0, 0, 1436, 847); // o
}
}
Note that currently the same index is used for all 3 arrays.
You may want to add a separate index variable for each array (e.g. currentObjectIndex, currentBackgroundIndex, currentGridIndex) that you can increment independently of each other.
I recommend having a bit more patience and double checking your code first.
Visualise what each line of code will do, then check if it actually does what you expect it to do. Either you will learn something new or improve your logic.
Also, if mentally joggling 3 arrays is tricky (and it can be), go one step back: try your logic with one array only until you get the hang of it, then move on.
A step backwards is sometimes a step forward when you're going in the wrong direction.
As creative as you'd like to be with Processing, bare in mind, the interface to plugging your ideas to it is still a series of one instruction at a time, each precisely tuned to do exactly what you want it to do. There's room for fun, but unfortunately you need to get past the boring parts first

change button image

I have created a new custom button, can I set a different background image instead of 'circle' or 'triangle' ?
thanks
Chanan
exporting: {
enabled: true,
buttons: {
'realTimeButton': {
id: 'realTimeButton',
symbol: 'diamond',
x: -88,
symbolFill: realTimeColor,
hoverSymbolFill: realTimeColor,
_titleKey: "realTimeButtonTitle",
onclick: function(event) {
// handle change to real time
if ( enable_lastRoundsChart_realtime )
{
// disable real time flag
enable_lastRoundsChart_realtime = 0;
// re-create detail in real time mode disabled
createDetail(cache_last_rounds.last_rounds_data, window.show_top_round_ids);
// enable plotBand
if ( pb_master_chart )
{
pb_master_chart.options.chart.events.selection.enabled = 'true';
pb_master_chart.options.chart.zoomType = 'x';
}
}
else
{
// enable real time flag
enable_lastRoundsChart_realtime = 1;
// re-create detail in real time mode enabled
createDetail(cache_last_rounds.last_rounds_data, window.show_top_round_ids);
// update title
this.setTitle({text:"Players/Drops Per Round"}, {text:"Real Time"});
// if master found, remove plotBand and disable master selection
if ( pb_master_chart )
{
// remove plotBand
pb_master_chart.xAxis[0].removePlotBand('mask-before');
pb_master_chart.xAxis[0].removePlotBand('mask-after');
pb_master_chart.xAxis[0].addPlotBand({
id: 'mask-before',
from: -1,
to: 99999,
color: 'rgba(0, 0, 0, 0.2)'
})
// disable selection
pb_master_chart.options.chart.events.selection.enabled = 'false';
pb_master_chart.options.chart.zoomType = null;
}
}
}
},
According to the docs, the shapes are defined in the Highcharts.Renderer.symbols collection. Inspecting this object reveals the following available shapes:
Highcharts.Renderer.prototype.symbols:
arc: function (a,b,c,d,e){var f=e.start,c=e.r||c||d,g=e.end-1.0E-6,d=e.innerR,h=e.open,i=W(f),j=Z(f),k=W(g),g=Z(g),e=e.end-f<Aa?0:1;return["M",a+c*i,b+c*j,"A",c,c,
circle: function (a,b,c,d){var e=0.166*c;return["M",a+c/2,b,"C",a+c+e,b,a+c+e,b+d,
diamond: function (a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d/2,a+c/2,b+d,a,b+d/2,"Z"]}
exportIcon: function (a,b,c,d){return y(["M",a,b+c,"L",a+c,b+d,a+c,b+d*0.8,a,b+d*0.8,"Z","M",a+c*0.5,b+d*0.8,"L",a+c*0.8,b+d*0.4,a+c*0.4,b+d*0.4,a+c*0.4,b,a+c*0.6,b,a+c*0.6,b+d*0.4,a+c*0.2,b+d*0.4,"Z"])}
printIcon: function (a,b,c,d){return y(["M",a,b+d*0.7,"L",a+c,b+d*0.7,a+c,b+d*0.4,a,b+d*0.4,"Z","M",a+c*0.2,b+d*0.4,"L",a+c*0.2,b,a+c*0.8,b,a+c*0.8,b+d*0.4,"Z","M",a+c*0.2,b+d*0.7,"L",a,b+d,a+
square: function (a,b,c,d){return["M",a,b,"L",a+c,b,a+c,b+d,a,b+d,"Z"]}
triangle: function (a,b,c,d){return["M",a+c/2,b,"L",a+c,b+d,a,b+d,"Z"]}
triangle-down: function (a,b,c,d){return["M",a,b,"L",a+c,b,a+c/2,b+d,"Z"]}
You can also add your own symbol by extending the collection. For example, drawing a simple X:
$.extend(Highcharts.Renderer.prototype.symbols, {
anX: function (a,b,c,d){return["M",a,b,"L",a+c,b+d,"M",a+c,b,"L",a,b+d]}
});
Produces:
Fiddle here.
You have ability to set image as icon
http://jsfiddle.net/Udgb3/
symbol: 'url(http://highcharts.com/demo/gfx/sun.png)',
symbolX:5,
symbolY:0

Resources